//
//  AFNetManager.m
//  TestJSPay
//
//  Created by hongliang on 16/3/26.
//  Copyright © 2016年 hongliang. All rights reserved.
//

#import "AFNetManager.h"

//NSString * const HTTPBaseURLString = @"http://101.201.29.69:8080";
//NSString * const HTTPBaseURLString = @"https://101.201.29.69:8081";
NSString * const HTTPBaseURLString = @"https://pay.hengantang.net";

NSString * const HTTPResDataKey = @"data";
NSString * const HTTPErrorDomain = @"http.TestJSPay";

@implementation AFNetManager
+ (instancetype)sharedInstance {
    static AFNetManager* afNetManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        afNetManager = [[AFNetManager alloc]init];
    });
    
    return afNetManager;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        _afHTTPSessionManager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:HTTPBaseURLString]];
        [_afHTTPSessionManager setRequestSerializer:[AFJSONRequestSerializer serializer]];

        AFSecurityPolicy *securityPolicy = [AFSecurityPolicy defaultPolicy];
        securityPolicy.allowInvalidCertificates = YES;
        _afHTTPSessionManager.securityPolicy = securityPolicy;
    }
    
    return self;
}

- (NSString*)apiPrefix {
    return @"api-rest/";
}
@end
